/*
day81
2019.11.17
*/

struct TreeNode {
	int val;
	struct TreeNode *left;
	struct TreeNode *right;
};

void help(struct TreeNode *root,int cur,int sum[])
{
	cur=cur*10+root->val;
	if(!root->left && !root->right) sum[0]+=cur;
	
	else if(!root->left) help(root->right,cur,sum);
	else if(!root->right) help(root->left,cur,sum);
	
	else if(root->right&&root->left) 
	{
		help(root->right,cur,sum);
		help(root->left,cur,sum);
	}
}

int sumNumbers(struct TreeNode* root)
{
	if(!root) return 0;
	
	int sum[]={0};
	help(root,0,sum);
	return sum[0];
}


int main()
{
	return 0;
}
